<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: order_details_wish_list.php 135 2013-09-22 07:30:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 135 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:30:55 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require(DIR_FS_INC.'inc.check_stock.php');

$module_smarty = new Smarty;
$module_smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/');

$module_content = array();
$any_out_of_stock = '';
$mark_stock = '';

for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
  	if (STOCK_CHECK == 'true') {
    	$mark_stock= check_stock($products[$i]['id'], $products[$i]['quantity']);
    	if ($mark_stock) 
    		$_SESSION['any_out_of_stock'] = 1;
    }
	
	$attributes_exist = ((isset($products[$i]['attributes'])) ? true : false);
	
  	$p_price = ($attributes_exist ? $price->format($products[$i]['price']*$products[$i]['quantity'], true) : $price->format($products[$i]['single_price'] * $products[$i]['quantity'], true));

  	$module_content[$i] = array('FORM' => draw_form('wish_list_form', href_link(FILENAME_WISH_LIST, get_all_get_params(array('action')).'action=add_product')).draw_hidden_field('products_id', $products[$i]['id']),
						  		'PRODUCTS_NAME' => $products[$i]['name'].$mark_stock,
						  		'PRODUCTS_QTY' => draw_input_field('cart_quantity', $products[$i]['quantity'], 'size="2" class="products_qty"'),
						  		'PRODUCTS_MODEL' => $products[$i]['model'],
						        'PRODUCTS_TAX' => number_format($products[$i]['tax'], TAX_DECIMAL_PLACES),
						  		'PRODUCTS_IMAGE' => $products[$i]['image'],
						  		'PRODUCTS_VPE' => $products[$i]['vpe'],
								'PRODUCTS_WEIGHT' => $products[$i]['weight'],
						  		'IMAGE_ALT' => $products[$i]['name'],
						  		'PRODUCTS_LINK' => href_link(FILENAME_PRODUCT_INFO, 'products_id='.$products[$i]['id']),
						  		'PRODUCTS_SINGLE_PRICE' => $price->format($products[$i]['single_price'], true),
						        'PRODUCTS_PRICE' => $p_price,
								'PRODUCTS_PLUS' => href_link(FILENAME_WISH_LIST, 'wl_plus='.$products[$i]['id']),
								'PRODUCTS_MINUS' => href_link(FILENAME_WISH_LIST, 'wl_minus='.$products[$i]['id']),
								'PRODUCTS_DELETE' => href_link(FILENAME_WISH_LIST, 'wl_delete='.$products[$i]['id']),
						  		'ATTRIBUTES' => '',
						        'BUY_NOW' => image_submit('button_buy_now.gif', TEXT_NOW));

    if ($attributes_exist == 1) {
	      reset($products[$i]['attributes']);

      while (list($option, $value) = each($products[$i]['attributes'])) {

          if (ATTRIBUTE_STOCK_CHECK == 'true' && STOCK_CHECK == 'true') {
            $attribute_stock_check = check_stock_attributes($products[$i][$option]['products_attributes_id'], $products[$i]['quantity']);
            if ($attribute_stock_check) $_SESSION['any_out_of_stock']=1;
          }

      $module_content[$i]['ATTRIBUTES'][]=array(
      			'ID' =>$products[$i][$option]['products_attributes_id'],
      			'MODEL'=>$products[$i][$option]['products_options_model'],
      			'NAME' => $products[$i][$option]['products_options_name'],
      			'PRICE' => ($products[$i][$option]['products_options_name'] != 'Downloads')?$price->format($products[$i][$option]['options_values_price'] * $products[$i]['quantity'],true):'',
				'PREFIX' =>  ($products[$i][$option]['products_options_name'] != 'Downloads')?$products[$i][$option]['price_prefix']:'',
      			'VALUE_NAME' => $products[$i][$option]['products_options_values_name'].$attribute_stock_check);
		}
    }
}

$total_content='';
if($_SESSION['customers_status']['customers_status_ot_discount_flag'] == '1' && $_SESSION['customers_status']['customers_status_ot_discount'] != '0.00') {
	$discount = recalculate_price($_SESSION['wish_list']->show_total(), $_SESSION['customers_status']['customers_status_ot_discount']);
    $total_content= $_SESSION['customers_status']['customers_status_ot_discount'].'% '.SUB_TITLE_OT_DISCOUNT.' -'.format_price($discount, $price_special=1, $calculate_currencies = false) .'<br />';
}

if($_SESSION['customers_status']['customers_status_show_price'] == '1')
	$total_content.= $price->format($_SESSION['wish_list']->show_total(),true);
else
	$total_content.= TEXT_INFO_SHOW_PRICE_NO;

if($customer_status_value['customers_status_ot_discount'] != 0)
	$total_content.= TEXT_CART_OT_DISCOUNT.$customer_status_value['customers_status_ot_discount'].'%';

if($_SESSION['customers_status']['customers_status_show_price'] == '1') {
	if(sizeof($products) == 1)
		$info_text = sprintf(HEAD_INFO_TXT,sizeof($products)).$total_content;
	else
		$info_text = sprintf(HEAD_INFO_TXT_MORE,sizeof($products)).$total_content;
}

$module_smarty->assign('HEAD_INFO', $info_text);
$module_smarty->assign('language', $_SESSION['language']);
$module_smarty->assign('module_content',$module_content);
$module_smarty->caching = false;
$module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/wish_list_order_details.html');
$smarty->assign('MODULE_order_details',$module);
?>